
const cloud = require('wx-server-sdk')
cloud.init({
  env: cloud.DYNAMIC_CURRENT_ENV
});
const db = cloud.database()

exports.main = async (event, context) => {
  const {account}=event.data

  try{
    const repeat=await db.collection("student").where(
      {
        account:account
      }
    ).get();
    if(repeat.data.length==1){
      try{
        const up=await db.collection("student").where({
          account:account
        }).update({
          data:{
            health_insurance_check:1
          }
        })
          return {success:true,message:"成功"}
      }catch(error){
          console.error(error);
          return{success:false,message:"0"+error}
      }
    }
    else{
      return {success:false,message:"失败"}
    }
  }catch(error){
    return{success:false,message:"1"}
  }
}